﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Common.Utils;
using Common.ViewModels;

namespace PlatingLineUI.Windows
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = ProductLine.Instance;
        }

        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            //MessageAggregator<LoadedMsg>.Publish(new LoadedMsg());
        }

        private void Btn属性修改_OnClick(object sender, RoutedEventArgs e)
        {
            Button btn= sender as Button;
            ReflexBuildControl.AddWindow(btn.DataContext);

        }

        private void ProductLineHanded(object sender, MouseButtonEventArgs e)
        {
            ProductLine.Instance.SelectValue = ProductLine.Instance;
        }

        private void Btn刷新_Click(object sender, RoutedEventArgs e)
        {
            MessageAggregator<LoadedMsg>.Publish(new LoadedMsg());
        }

        private void TreeViewItem_OnSelected(object sender, RoutedEventArgs e)
        {
          
            if (treeView.SelectedItem is TreeViewItem treeViewItem)
            {
                ProductLine.Instance.SelectValue = treeViewItem.DataContext;
            }
            else
            {
                ProductLine.Instance.SelectValue = treeView.SelectedItem;
                //ProductLine.Instance.SelectValue = sender;
            }
            //var d=  treeView.SelectedItem;
        }
    }
}
